﻿using System.Data.Entity.ModelConfiguration;

using NeGroid.ChampionshipManager.Core;

namespace NeGroid.ChampionshipManager.Persistance.Mappings
{
	public class PlayerTransferMap : EntityTypeConfiguration<PlayerTransfer>
	{
		public PlayerTransferMap()
		{
			HasKey(t => t.Id);

			HasRequired(t => t.Player)
				.WithMany()
				.HasForeignKey(t => t.PlayerId);
			HasRequired(t => t.TeamFrom)
				.WithMany()
				.HasForeignKey(t => t.TeamFromId)
				.WillCascadeOnDelete(false);
			HasRequired(t => t.TeamTo)
				.WithMany()
				.HasForeignKey(t => t.TeamToId)
				.WillCascadeOnDelete(false);

			ToTable("Transfers");
		}
	}
}
